package com.service.impl;

import java.util.List;

import com.dao.BookDao;
import com.dao.OrderDao;
import com.dao.impl.BookDaoImpl;
import com.dao.impl.OrderDaoImpl;
import com.model.Book;
import com.model.BookTopVo;
import com.model.Order;
import com.model.OrderDetail;
import com.service.BookService;

public class BookServiceImpl implements BookService {

	private BookDao bookDao = new BookDaoImpl();

	private OrderDao orderDao = new OrderDaoImpl();

	@Override
	public List<Book> queryNewBooksInfo() {

		return bookDao.queryNewBooksInfo();
	}

	@Override
	public List<Book> queryDiscountBooksInfo() {

		return bookDao.queryDiscountBooksInfo();
	}

	@Override
	public List<Book> queryHotBooksInfo() {

		return bookDao.queryHotBooksInfo();
	}

	@Override
	public Book queryBookById(Integer id) {

		return bookDao.queryBookById(id);
	}

	@Override
	public List<OrderDetail> queryOrderListByUserName(String userName) {

		return orderDao.queryOrderListByUserName(userName);
	}

	@Override
	public int insertOrder(Order order) {

		return orderDao.insert(order);
	}

	@Override
	public boolean insertOrderDetails(List<OrderDetail> orderDetails) {

		return orderDao.insertOrderDetails(orderDetails) > 0;
	}

	@Override
	public int querBookCount(Integer type, String bookName) {

		return bookDao.querBookCount(type,bookName);
	}

	@Override
	public List<Book> queryBooksWithPage(Integer curPage, Integer pageSize, Integer type) {

		return bookDao.queryBooksWithPage(curPage,pageSize,type);
	}

	@Override
	public List<Book> queryLeftHotBooks(String typeName, Integer type) {

		return bookDao.queryLeftHotBooks(typeName,type);
	}

	@Override
	public List<Book> queryBooksByTypeName(String typeName) {

		return bookDao.queryBooksByTypeName(typeName);
	}

	@Override
	public List<BookTopVo> queryTopBooksInfo() {

		return bookDao.queryTopBooksInfo();
	}

	@Override
	public boolean deleteBookById(Integer id) {
		Book book = new Book();
		book.setId(id);
		return bookDao.delete(book) > 0;
	}

	@Override
	public int queryBookCount() {

		return bookDao.queryBookCount();
	}

	@Override
	public Book queryBookByName(String bookName) {

		return bookDao.queryBookByName(bookName);
	}

	@Override
	public boolean insertBook(Book book) {

		return bookDao.insert(book) > 0;
	}

	@Override
	public boolean updateBook(Book book) {

		return bookDao.update(book) > 0;
	}

	@Override
	public Order querOrderById(int id) {

		return orderDao.queryOrderById(id);
	}

	@Override
	public boolean sendOrder(int id) {

		return orderDao.sendOrderById(id) > 0;
	}

	@Override
	public int queryOrderCount() {

		return orderDao.queryOrderCount();
	}

	@Override
	public List<Order> queryOrdersWithPage(Integer curPage, Integer pageSize) {

		return orderDao.queryOrdersWithPage(curPage, pageSize);
	}

	@Override
	public List<OrderDetail> queryOrderDetailsByOrderId(int id) {

		return orderDao.queryOrderDetailsByOrderId(id);
	}

	@Override
	public boolean receiveOrder(Integer id) {
		// TODO Auto-generated method stub
		return orderDao.receiveOrder(id)>0;
	}

}
